1. Field of the Invention
Embodiments of the present invention relate generally to computer graphics systems and more specifically to coverage adaptive multisampling.
2. Description of the Related Art
Computer graphics systems render images on a two-dimensional grid of pixels that is characterized by a discrete horizontal and vertical quantization resolution. The images may be displayed on a display device or stored for later use. The finite resolution of a rendered image often results in visual artifacts, known generally as “aliasing” artifacts, when the ability of a viewer to resolve spatial resolution exceeds the finite spatial resolution of the rendered image. The visual artifacts associated with aliasing typically appear as jagged edges on object silhouettes or along the intersection of two or more objects. Very small or thin objects may tend to flicker. Another type of aliasing artifact results when the coloration (shading) of pixels varies greatly over a pixel region but the pixel's shading is computed without sufficient sampling over the pixel, typically because the shading is computed at a single location within the pixel. This type of shading aliasing produces noisy or flickering shading results, particularly when animation is involved.
Techniques for reducing the artifacts associated with aliasing are referred to as “antialiasing” techniques. Supersampling and multisampling are two well-known antialiasing techniques. Supersampling increases the spatial rendering resolution of an image by using multiple samples that are fully rendered for every pixel within the final image. For example, a supersampling system may generate a pixel by combining four samples, each typically including independently textured and shaded color, depth and coverage information. The four samples are combined using well-known techniques to produce one pixel in the final image, which benefits in general from the increased inherent spatial rendering resolution provided by the additional samples. Supersampling also reduces both edge and shading artifacts due to aliasing because both coverage and shading are performed at more than one sample per pixel.
When the supersampling system performs texture mapping, each of the four samples within a pixel is usually texture mapped separately according to a specified texture mapping technique. For example, trilinear texture mapping may be used to independently texture each of the four samples, where the center of each sample is used to select a sample location within the associated texture map. The four color values, each generated from eight texels (thirty-two total texels), are combined to generate the color value for the pixel. While supersampling produces very high-quality results, the associated bandwidth and processing load increases in proportion to the number of samples within a pixel, making this technique prohibitively expensive in many scenarios.
Multisampling substantially reduces memory bandwidth and processing load relative to supersampling by eliminating the independent color computation for each sample within a pixel (while preserving the independent computation of depth and coverage for each sample). Instead of texturing and shading each sample color independently, one representative sample point is selected for color shading. The resulting color is applied to all samples within the pixel. The underlying assumption of multisampling is that the color of a given shaded object will not change rapidly within the boundaries of a single pixel and therefore using a single representative color sample for the pixel on the object is adequate. However, since intersecting objects may have very different colors within the area of a single pixel, preserving depth and coverage information is important to accurately represent an intersection of two or more objects within the boundaries of the pixel.
When a multisampling system performs texture mapping, a representative sample point is selected for the purpose of texture mapping the pixel and the resulting texture map color is attributed to all of the samples within the pixel. Well-known techniques exist for selecting the representative sample point, however the process is fundamentally an approximation. For example, basic multisampling selects the pixel center as the representative sample point for shading the entire pixel. When the texture mapped object is relatively large and parallel with the current view plane of a rendered image, the resulting image quality is generally acceptable because variations in the position of the representative sample point have little effect on the location of the sample point within the texture map. However, as the angle of incidence from the view plane to the surface of the texture mapped object increases, small variations in the position of the representative sample point result is large excursions through the texture map image. For example, if the pixel center is used to define the sample point, but the geometric primitive does not actually intersect the pixel center, then the pixel may be shaded with erroneous texture data. In certain scenarios, such as when “atlas” textures (unrelated image panels consolidated into one flat texture map image) are used, striking visual errors may result when an extrapolated sample point from one texture mapped object strays off the atlas panel and into a panel that has no relationship to the texture mapped object.
One well-known technique used to improve image quality of texture mapping in multisampling systems is called “centroid sampling.” Centroid sampling, which is a well-known multisampling technique, attempts to guarantee that the representative sample point is located on a covered portion of the texture mapped object by placing the representative sample at the centroid of covered samples. While centroid sampling improves overall image quality in certain basic instances, this technique is still an approximation and does not completely eliminate artifacts in all common scenarios. For example, objects that occupy one or a small number of screen space pixels may not be properly shaded.
In addition, centroid sampling causes texture map address computation resources to generate non-uniformly spaced texture map addresses, rather than evenly spaced texture map addresses that can also be used to compute the partial derivatives needed in level-of-detail (LOD) computations. As a consequence, additional resources are needed to perform LOD computations in a centroid sampling system to avoid artifacts related to erroneous LOD computation.
Another approach to improving the image quality in the presence of multisampling is transparency adaptive multisampling. In essence, this approach resorts to supersampling when semi-transparent (non-fully opaque) objects are rendered. The rationale is that transparent objects are often alpha tested. The alpha color component reflects the degree of opacity. When the opacity is below some threshold, such fragments are discarded. However, if the alpha color component, computed as part of a shading operation, is computed once per pixel and shared with all the samples used for multisampling, then all samples for a given pixel are either discarded or kept as a single group. This leads to jagged edges when semi-transparent objects are rendered. To avoid this problem, transparency adaptive multisampling simply resorts to supersampling instead of multisampling when rendering semi-transparent objects. The overall benefit of transparency adaptive multisampling is therefore limited to improving the rendered quality of transparent objects. However, transparency adaptive multisampling introduces a potential performance inefficiency by unnecessarily supersampling pixels for certain rendered objects that have non-opaque and fully opaque regions, as is often the case for objects like trees and vegetation. Additionally, transparency adaptive multisampling does not improve image quality for non-transparent objects subject to aliasing artifacts due to under-sampled shading. Thus, the applicability of transparency adaptive multisampling is limited because this technique adapts the use of supersampling or multisampling on a coarse basis that is specialized for the specific case of transparent objects.
As the foregoing illustrates, what is needed in the art is an antialiasing technique that provides the high performance and low resource utilization similar to multisampling, while also providing the high image quality that is comparable with supersampling.